<?php


/**
 * helper function to transform normal form to horizontal form
 *
 * @param $form
 */
function _transform_horizontal_form(&$form) {
  $bootstrap = array(
    'form_class' => 'form-horizontal',
    'label_class' => 'col-sm-4',
    'control_class' => 'col-sm-8',
    'offset_class' => 'col-sm-offset-4',
  );

  if(isset($form['actions']['submit'])) {
    $form['actions']['submit']['#crabii_app_form_element_alter_skip'] = TRUE;
  }
  else if(isset($form['submit'])) {
    $form['submit']['#crabii_app_form_element_alter_skip'] = TRUE;
  }

  CommonHelper::element_children_alter($form, 'helper_form_element_alter', $bootstrap);
}

/**
 * helper funciton to transform normal page to simple page
 */
function _transform_simple_page() {
  $crabii_theme_customization = &drupal_static('crabii_theme_customization');
  if (!isset($crabii_theme_customization)) {
    $crabii_theme_customization = array(
      'page_template' => 'page__simple',
      'show_messages' => FALSE,
    );
  }
}

/**
 * helper for processing password and change second password field label to "Password again"
 *
 * @see crabii_process_password_confirm()
 */
function _process_password(&$form) {
  // Get default process function array for password confirm field:
  $element_info = element_info('password_confirm');
  $process = $element_info['#process'];
  // Add our process function to the array:
  $process[] = 'crabii_process_password_confirm';
  $form['account']['pass']['#process'] = $process;
}
